﻿package code
{
	import flash.events.Event;
	
	public class CandyCorn extends GenericEnemy
	{
		var gun:EnemyWeapon;

		public function CandyCorn(scrollFactor:int, spawnX:int, spawnY:int)
		{
			trace(this + "was created");
			super(spawnX, spawnY, 100);
			this.scaleX = this.scaleY = .25;
			this.trigger();
			this.vy = scrollFactor;
			
			gun = new EnemyWeapon(0,0, 3, 500, 1500, BulletType.JELLYBEAN);
			this.addChild(gun);
			
			this.addEventListener(Event.ADDED_TO_STAGE, triggerWeapon);
		}
		
		public override function update():void
		{
			super.update();
			gun.update();
		}
		
		private function triggerWeapon(e:Event)
		{
			gun.trigger();
			
			this.removeEventListener(Event.ADDED_TO_STAGE, triggerWeapon);
		}

	}
}